<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="css/eui.css">
    <style>
        body {
            font: 18px "Microsoft YaHei UI";
            margin: 0;
            padding: 0;
            /*vertical-align: center;*/
        }

        header, main, footer {
            margin: 0 !important;
            padding: 0 !important;
        }

        a {
            text-decoration: none;
            color: #333333;
        }

        #header_div1 .el-menu--horizontal > .el-menu-item, #header_div1 .el-menu--horizontal > .el-submenu .el-submenu__title {
            height: 36px;
            line-height: 36px;
        }

        #header_div1 .el-menu-item, #header_div1 .el-submenu__title {
            font-size: 12px;
        }

        .header_span_a {
            margin-right: 20px;
            margin-left: 20px;
            color: white;
            font-size: 12px;
        }

        .el-menu--horizontal > .el-menu-item.is-active {
            border-bottom: white;
        }

        #header_div2 .el-menu--horizontal > .el-menu-item {
            height: 80px;
            line-height: 80px;
        }

        #header_div2 .el-menu-item, #header_div2 .el-submenu__title {
            font-size: 18px;
            padding: 0 40px 0 0;
        }
        .el-button--primary{
            background-color: #392f41;
            border: #392f41;
        }
        .el-button--primary:hover{
            background-color: rgba(57,47,65,0.8);
        }
        #login_div1{
            background-image: url('imgs/ab.jpg');
            background-size: 80px 80px;
            background-repeat: no-repeat;
            height: 120px;
            background-position: 42%;
        }
    </style>
</head>
<body>
<div id="app">
    <el-container>
        <el-header style="height: 36px;width: 1520px; margin: 0 auto">
            <!-- 黑条开始 -->
            <div style="height: 36px; line-height: 36px;background-color: #392f41">
                    <span style="margin-left: 105px">
                        <a class="header_span_a" href="/">首页</a><el-divider direction="vertical"></el-divider>
                        <a class="header_span_a" href="">猎者商城</a><el-divider direction="vertical"></el-divider>
                        <a class="header_span_a" href="">猎者俱乐部</a>
                    </span>
                <div id="header_div1" style="float: right; margin-right: 120px">
                    <el-menu
                            class="el-menu-demo"
                            mode="horizontal"
                            background-color="#392f41"
                            text-color="#fff"
                            @select="handleSelect"
                            active-text-color="#ffd04b">
                        <el-menu-item index="login">请登录</el-menu-item>
                        <el-menu-item index="reg">注册</el-menu-item>
                        <el-menu-item index="myorder">我的订单</el-menu-item>
                        <el-menu-item index="shoppingcart">购物车</el-menu-item>
                        <el-submenu index="5">
                            <template slot="title">客服</template>
                            <el-menu-item index="5-1" style="text-align: center">在线客服</el-menu-item>
                            <el-menu-item index="5-2">
                                <i class="el-icon-phone" style="color: white"></i>电话客服 : 400-000-0000
                            </el-menu-item>
                        </el-submenu>
                    </el-menu>
                </div>
            </div>
            <!-- 黑条结束 -->
        </el-header>
        <el-main style="text-align: center">
            <div id="login_div1">
                <h1 style="line-height: 120px; padding-left: 160px">欢迎来到猎者外设商城</h1>
            </div>
            <el-divider></el-divider>
            <div id="login_div2" style="margin: 0 auto">
                <el-row justify="center" type="flex" >
                    <el-col span="8" >
                        <el-form label-width="100px">
                            <el-form-item label="用户名">
                                <el-input type="text" v-model="user.username" placeholder="请输入用户名"></el-input>
                            </el-form-item>
                            <el-form-item label="密码">
                                <el-input type="password" v-model="user.password" placeholder="请输入密码"></el-input>
                            </el-form-item>
                            <el-form-item>
                                <el-button type="primary" @click="login()">登录</el-button>
                            </el-form-item>
                        </el-form>
                    </el-col>
                </el-row>
            </div>
        </el-main>
    </el-container>

</div>
</body>
<script src="js/vue.min.js"></script>
<!-- import JavaScript -->
<script src="js/eui.js"></script>
<script src="js/axios.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {
                user: {
                    password: '',
                    username: ''
                }
            }
        },
        methods: {
            login(){
                axios.post("/user/login",v.user).then(function (response){
                    if(response.data == 1){
                        v.$message({
                            message: '登录成功!',
                            type: 'success'
                        });
                        location.href = "/";
                    }
                })
            },
            handleSelect(index) {
                console.log(index);
                //传递过来的index 其实就是分类的id
                //跳转到新的页面显示这个分类下的商品信息
                if (index == "login") {//判断出点击的不是搜索框
                    location.href = "/login.html";
                }else if (index == "reg"){
                    location.href = "/reg.html";
                }else  if (index == "myorder"){
                    location.href = "/usercommodityorder.html?name="+1;
                }else if (index == "shoppingcart"){
                    location.href = "/usercommodityorder.html?name="+2;
                }else if (index != -1){
                    location.href == "/result.html?cid=" + index;
                }
            }
        }
    })
</script>
</html>